package com.example.room_demo

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import androidx.room.Delete

@Dao
interface DataDao {
    //插入数据
    @Insert()
    fun insert(data: DataBean)

    //删除数据---单个删除
    @Query("DELETE FROM data_table where game_name=:name")
    fun delete(name: String): Int

    //修改数据
    @Query("UPDATE data_table SET game_name= :newName WHERE game_name = :name")
    fun update(newName: String, name: String): Int

    //查询数据
    @Query("SELECT * FROM data_table")
    fun getDatas(): MutableList<DataBean>

    //删全部
    @Query("DELETE FROM data_table")
    fun deleteAll(): Int

    //模糊查询
    @Query("SELECT * FROM data_table WHERE game_name LIKE '%' || :name || '%' ")
    fun fuzzyQuery(name: String): MutableList<DataBean>

}